package com.feilx.changgou.goods.controller;

import java.util.Arrays;
import java.util.Map;


import com.changgou.bean.PageVo;
import com.changgou.bean.QueryCondition;
import com.changgou.bean.Resp;
import com.changgou.pojo.TbSpuEntity;
import com.feilx.changgou.goods.service.TbSpuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;





/**
 *
 *
 * @author feilx
 * @email 852371260@qq.com
 * @date 2020-08-01 14:05:04
 */
@Api(tags = " 管理")
@RestController
@RequestMapping("pms/tbspu")
public class TbSpuController {
    @Autowired
    private TbSpuService tbSpuService;

    /**
     * 列表
     */
    @ApiOperation("分页查询(排序)")
    @GetMapping("/list")
    public Resp<PageVo> list(QueryCondition queryCondition) {
        PageVo page = tbSpuService.queryPage(queryCondition);

        return Resp.ok(page);
    }


    /**
     * 信息
     */
    @ApiOperation("详情查询")
    @GetMapping("/info/{id}")
    public Resp<TbSpuEntity> info(@PathVariable("id") Long id){
		TbSpuEntity tbSpu = tbSpuService.getById(id);

        return Resp.ok(tbSpu);
    }

    /**
     * 保存
     */
    @ApiOperation("保存")
    @PostMapping("/save")
    public Resp<Object> save(@RequestBody TbSpuEntity tbSpu){
		tbSpuService.save(tbSpu);

        return Resp.ok(null);
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @PostMapping("/update")
    public Resp<Object> update(@RequestBody TbSpuEntity tbSpu){
		tbSpuService.updateById(tbSpu);

        return Resp.ok(null);
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @PostMapping("/delete")
    public Resp<Object> delete(@RequestBody Long[] ids){
		tbSpuService.removeByIds(Arrays.asList(ids));

        return Resp.ok(null);
    }

}
